package com.sanyang.pda.adapter;

import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sanyang.pda.bean.HaveTestedBean;
import com.wangshen.base.ui.mvp.base.adapter.BaseAdapter;
import com.wangshen.projectbase.R;

import java.util.List;

public class HaveTestedAdapter extends BaseAdapter<HaveTestedBean> {
    public HaveTestedAdapter(int layoutResId, @Nullable List<HaveTestedBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HaveTestedBean item) {
        super.convert(helper, item);
        helper.setText(R.id.tv_samplingno,item.getSamplingNo());
        helper.setText(R.id.tv_checkindexno,item.getCheckIndexNo()+"");
        helper.setText(R.id.tv_articlename,item.getArticleName());
        helper.setText(R.id.tv_spec,item.getSpec());
        helper.setText(R.id.tv_batchno,item.getBatchNo());
        helper.setText(R.id.tv_checknum,item.getCheckNum()+"");
        helper.setText(R.id.tv_backpallet,item.getBackPallet());
        helper.setText(R.id.tv_backstoragebinid,item.getBackStoragebinId());
        helper.setText(R.id.tv_qualifiedstatuscn,item.getQualifiedStatusCn());
        LinearLayout llReason=helper.getView(R.id.ll_reason);
        if (item.getQualifiedStatus() == 10){
            llReason.setVisibility(View.GONE);
            helper.setTextColor(R.id.tv_qualifiedstatuscn,getContext().getResources().getColor(R.color._0D73EC));
        }else {
            llReason.setVisibility(View.VISIBLE);
            helper.setText(R.id.tv_reason,item.getReason());
            helper.setTextColor(R.id.tv_qualifiedstatuscn,getContext().getResources().getColor(R.color._EABD35));
        }
        CheckBox checkBox=helper.getView(R.id.cb_open);
        LinearLayout linearLayout=helper.getView(R.id.ll_open);
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    linearLayout.setVisibility(View.VISIBLE);
                }else {
                    linearLayout.setVisibility(View.GONE);
                }
            }
        });
    }
}
